import { createStore } from 'vuex'
import persist from 'vuex-persistedstate'
export default createStore({
  state: {
    history:[], // 存放历史记录的
  },
  mutations: {
    addhis(state,val){
      let i = state.history.findIndex(item => item == val);
      if (i>-1){
        state.history.splice(i,1);
      } 
      state.history.unshift(val);
    },
    delectAll(state){ // 全部删除
      state.history = [];
    },
    delect(state,i){ // 单个删除
      state.history.splice(i,1);
    }
  },
  actions: {
  },
  modules: {
  },
  plugins: [
    new persist({
      storage: window.localStorage,
    }),
  ],
})
